package com.wanshi.dao;

import com.wanshi.entity.Type;
import com.wanshi.utils.JDBCUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class TypeDao {

    //获取所有类型
    public List<Type> types(){
        String sql = "select * from type";
        QueryRunner runner = new QueryRunner(JDBCUtil.getSource());
        try {
            return runner.query(sql, new BeanListHandler<>(Type.class));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
